#include <iostream>
using std::cout;
using std::endl;

class Base {
public:
	Base(long x = 0)
    : _base(x)
    { 
        cout << "Base(long)" << endl;
    }

    ~Base(){
        cout << "~Base()" << endl;
    }
private:
	long _base;
};

class Test{
public:
	Test(long x = 0)
    : _test(x)
    { 
        cout << "Test(long)" << endl;
    }

    ~Test(){
        cout << "~Test()" << endl;
    }
private:
	long _test;
};


class Derived
: public Base 
{
public:
    //Derived构造函数中需要完成基类子对象的初始化
    //一般要手动调用基类的构造函数
    //如果没有手动调用基类构造函数，
    //编译器会自动调用基类的无参构造
    //或所有参数都有默认值的有参构造来完成基类子对象的初始化
	Derived(long base,long derived,long test)
    : Base(base) //基类子对象的初始化写的是基类的类名
	, _derived(derived)
    , _t1(test)//成员子对象的初始化写的是成员名字
    , _b1(base)
	{ 
        cout << "Derived(long,long)" << endl; 
    }

    ~Derived(){
        cout << "~Derived()" << endl;
    }
private:
	long _derived;
    Test _t1;
    Base _b1;
};

void test0(){
    Derived d1(2,4,6);
}

int main(void){
    test0();
    return 0;
}
